package com.example.application;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import com.example.kafka.KafkaProducerService;
import com.example.flink.FlinkJobService;

import org.springframework.beans.factory.annotation.Autowired;

@SpringBootApplication
@ComponentScan(basePackages = "com.example")  // 确保扫描 KafkaProducerService 和 FlinkJobService
public class Application implements CommandLineRunner {

    @Autowired
    private KafkaProducerService kafkaProducerService;

    @Autowired
    private FlinkJobService flinkJobService;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        kafkaProducerService.produce("This is an important message");
        kafkaProducerService.produce("are you ok");


        flinkJobService.startFlinkJob();
    }
}
